// c:\users\de'l'l\desktop\lkchongxie\重写\pages\result\result
Page({
    data: {
        tools: [{
            name: '身体质量指数BMI',
            image: 'http://fcdn.qiushilaile.com/game/default-10121630635799293.jpg',
            bg: 'http://fcdn.qiushilaile.com/game/default-54861630635965891.jpg',
            btn: 'http://fcdn.qiushilaile.com/game/default-2621630635985498.png',
            value: '1',
            person: '123',
        }, {
            name: '中心性肥胖标准',
            image: 'http://fcdn.qiushilaile.com/game/default-53611630636085250.jpg',
            bg: 'http://fcdn.qiushilaile.com/game/default-12351630636097854.jpg',
            btn: 'http://fcdn.qiushilaile.com/game/default-53651630636105582.png',
            value: '2',
            person: '242',
        }, {
            name: '身体脂肪率',
            image: 'http://fcdn.qiushilaile.com/game/default-25431630636121182.jpg',
            bg: 'http://fcdn.qiushilaile.com/game/default-3741630636128869.jpg',
            btn: 'http://fcdn.qiushilaile.com/game/default-13211630636141474.png',
            value: '3',
            person: '66',
        }, {
            name: '每日所需卡路里',
            image: 'http://fcdn.qiushilaile.com/game/default-40711630636156746.jpg',
            bg: 'http://fcdn.qiushilaile.com/game/default-16581630636165497.jpg',
            btn: 'http://fcdn.qiushilaile.com/game/default-73891630636172100.png',
            value: '4',
            person: '56',
        }, {
            name: '健康体重范围',
            image: 'http://fcdn.qiushilaile.com/game/default-21981630636185582.jpg',
            bg: 'http://fcdn.qiushilaile.com/game/default-57741630636194597.jpg',
            btn: 'http://fcdn.qiushilaile.com/game/default-55311630636201332.png',
            value: '5',
            person: '123',
        }, {
            name: '运动健身补水',
            image: 'http://fcdn.qiushilaile.com/game/default-61671630636214269.jpg',
            bg: 'http://fcdn.qiushilaile.com/game/default-76661630636222595.jpg',
            btn: 'http://fcdn.qiushilaile.com/game/default-70831630636229698.png',
            value: '6',
            person: '123',
        }, {
            name: '跑步卡路里消耗',
            image: 'http://fcdn.qiushilaile.com/game/default-24311630636248876.jpg',
            bg: 'http://fcdn.qiushilaile.com/game/default-85541630636258270.jpg',
            btn: 'http://fcdn.qiushilaile.com/game/default-26551630636265646.png',
            value: '7',
            person: '123',
        }, ],
    },
    onLoad(query) {
        console.log(query);
        if (query.tools == 'bmi') {
            this.setData({
                bmi: query.bmi,
                value: query.value,
                header: '身体质量指数测试',
                resultImg: 'http://fcdn.qiushilaile.com/game/default-10761630662080014.jpg',
            })
        } else if (query.tools == 'cos') {
            if (query.value == '非中心性肥胖') {
                var img = 'http://fcdn.qiushilaile.com/game/default-14171630662234566.jpg';
            } else {
                var img = 'http://fcdn.qiushilaile.com/game/default-57711630662220833.jpg';
            }
            this.setData({
                cos: query.cos,
                value: query.value,
                header: '中心性肥胖标准测试',
                resultImg: img,
            })
        } else if (query.tools == 'bfr') {
            this.setData({
                bfr: query.bfr,
                value: query.value,
                header: '身体脂肪率测试',
                resultImg: 'http://fcdn.qiushilaile.com/game/default-43161630662248211.jpg',
            })
        } else if (query.tools == 'dcr') {
            this.setData({
                dcr: query.dcr,
                header: '每日所需卡路里测试',
                resultImg: 'http://fcdn.qiushilaile.com/game/default-81961630662260822.jpg',
            })
        } else if (query.tools == 'hwr') {
            this.setData({
                hwr: query.hwr,
                header: '健康体重范围测试',
                resultImg: 'http://fcdn.qiushilaile.com/game/default-43791630657334255.jpg',
            })
        } else if (query.tools == 'sfh') {
            this.setData({
                sfh: query.sfh,
                header: '运动健身补水测试',
                resultImg: 'http://fcdn.qiushilaile.com/game/default-39711630662272807.jpg',

            })
        } else if (query.tools == 'rcb') {
            this.setData({
                rcb: query.rcb,
                header: '跑步卡路里消耗测试',
                resultImg: 'http://fcdn.qiushilaile.com/game/default-20751630662282593.jpg',
            })
        }
    },
    save() {
        this.showMsg('保存图片')
    },
    clickTest(e) {
        console.log(e.currentTarget.dataset);
        let {
            name,
            value,
            bg,
            btn,
        } = e.currentTarget.dataset
        tt.navigateTo({
            url: '/pages/testing/testing?title=' + name +
                '&value=' + value +
                '&bg=' + bg +
                '&btn=' + btn
        });
    },
    toTest(e) { // 前往工具间（通用样式）
        let {
            value,
            person
        } = e.currentTarget.dataset;
        console.log(e.currentTarget.dataset);
        if (value == '1') {
            tt.navigateTo({
                url: '/pages/tools/bmi/bmi?value=' + value + '&person=' + person
            });
        } else if (value == '2') {
            tt.navigateTo({
                url: '/pages/tools/cos/cos?value=' + value + '&person=' + person
            });
        } else if (value == '3') {
            tt.navigateTo({
                url: '/pages/tools/bfr/bfr?value=' + value + '&person=' + person
            });
        } else if (value == '4') {
            tt.navigateTo({
                url: '/pages/tools/dcr/dcr?value=' + value + '&person=' + person
            });
        } else if (value == '5') {
            tt.navigateTo({
                url: '/pages/tools/hwr/hwr?value=' + value + '&person=' + person
            });
        } else if (value == '6') {
            tt.navigateTo({
                url: '/pages/tools/sfh/sfh?value=' + value + '&person=' + person
            });
        } else if (value == '7') {
            tt.navigateTo({
                url: '/pages/tools/rcb/rcb?value=' + value + '&person=' + person
            });
        }

    },
    onShareAppMessage(option) {
        return {
            title: this.data.title,
            desc: this.data.title,
            path: "/pages/home/home",
            templateId: "",
            success() {
                console.log('success');
            },
            fail() {
                console.log("转发发布器调起失败");
            },
        };
    },
    showMsg(n) { // 轻提示方法
        tt.showToast({
            title: n,
            icon: "none"
        });
    },
})